From 5749f310e4783c801371e2b876eb6379720f3800 Mon Sep 17 00:00:00 2001 From: Michael Fulbright Date: Fri, 29 Oct 1999 19:27:51 +0000 Subject: [PATCH] Actually load the image handler when we determine the image type. 1999-10-29 Michael Fulbright * src/gdk-pixbuf-loader.c (gdk_pixbuf_loader_write): Actually load the image handler when we determine the image type. * src/gdk-pixbuf-io.[ch] (gdk_pixbuf_load_module): Changed the previously static function load_image_handler () to a public function gdk_pixbuf_load_module (). It is needed in gdk-pixbuf-loader.c to load image handler modules. This function is different from gdk_pixbuf_get_module (), which only returns a reference to the required handler, because it actually loads the handler into memory. Both actions should possibly be combined in a convenience function since one w/o the other doesn't seem to make much sense. --- gdk-pixbuf/ChangeLog | 15 +++++++++++++++ gdk-pixbuf/gdk-pixbuf-io.c | 12 ++++++++---- gdk-pixbuf/gdk-pixbuf-io.h | 2 ++ gdk-pixbuf/gdk-pixbuf-loader.c | 11 +++++++---- gtk/gdk-pixbuf-loader.c | 11 +++++++---- 5 files changed, 39 insertions(+), 12 deletions(-) diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index ec22354fcb..694aa663e0 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,18 @@ +1999-10-29 Michael Fulbright + + * src/gdk-pixbuf-loader.c (gdk_pixbuf_loader_write): Actually + load the image handler when we determine the image type. + + * src/gdk-pixbuf-io.[ch] (gdk_pixbuf_load_module): Changed the + previously static function load_image_handler () to + a public function gdk_pixbuf_load_module (). It is needed in + gdk-pixbuf-loader.c to load image handler modules. This function + is different from gdk_pixbuf_get_module (), which only returns + a reference to the required handler, because it actually loads + the handler into memory. Both actions should possibly be combined + in a convenience function since one w/o the other doesn't seem to + make much sense. + 1999-10-28 Federico Mena Quintero * src/gdk-pixbuf-render.c (gdk_pixbuf_render_to_drawable): New diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c index 16c8049e53..e2b692f6d9 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.c +++ b/gdk-pixbuf/gdk-pixbuf-io.c @@ -149,8 +149,12 @@ GdkPixbufModule file_formats [] = { { NULL, NULL, NULL, NULL, NULL, NULL, NULL } }; -static void -image_handler_load (GdkPixbufModule *image_module) + +/* actually load the image handler - gdk_pixbuf_get_module only get a */ +/* reference to the module to load, it doesn't actually load it */ +/* perhaps these actions should be combined in one function */ +void +gdk_pixbuf_load_module (GdkPixbufModule *image_module) { char *module_name; char *path; @@ -240,7 +244,7 @@ gdk_pixbuf_new_from_file (const char *filename) image_module = gdk_pixbuf_get_module (buffer, size); if (image_module){ if (image_module->module == NULL) - image_handler_load (image_module); + gdk_pixbuf_load_module (image_module); if (image_module->load == NULL) { fclose (f); @@ -270,7 +274,7 @@ gdk_pixbuf_new_from_xpm_data (const gchar **data) GdkPixbuf *pixbuf; if (file_formats[XPM_FILE_FORMAT_INDEX].module == NULL) { - image_handler_load(&file_formats[XPM_FILE_FORMAT_INDEX]); + gdk_pixbuf_load_module(&file_formats[XPM_FILE_FORMAT_INDEX]); } if (file_formats[XPM_FILE_FORMAT_INDEX].module == NULL) { diff --git a/gdk-pixbuf/gdk-pixbuf-io.h b/gdk-pixbuf/gdk-pixbuf-io.h index 4486adfb66..2fcd092573 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.h +++ b/gdk-pixbuf/gdk-pixbuf-io.h @@ -6,6 +6,7 @@ * Miguel de Icaza * Federico Mena-Quintero * Jonathan Blandford + * Michael Fulbright * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -46,4 +47,5 @@ struct _GdkPixbufModule { GdkPixbufModule *gdk_pixbuf_get_module (gchar *buffer, gint size); +void gdk_pixbuf_load_module (GdkPixbufModule *image_module); diff --git a/gdk-pixbuf/gdk-pixbuf-loader.c b/gdk-pixbuf/gdk-pixbuf-loader.c index db734ef631..ddb4ad3eec 100644 --- a/gdk-pixbuf/gdk-pixbuf-loader.c +++ b/gdk-pixbuf/gdk-pixbuf-loader.c @@ -270,16 +270,19 @@ gdk_pixbuf_loader_write (GdkPixbufLoader *loader, guchar *buf, size_t count) priv->image_module = gdk_pixbuf_get_module (priv->buf, 128); if (priv->image_module == NULL) return FALSE; - else if ((priv->image_module->begin_load == NULL) || - (priv->image_module->stop_load == NULL) || - (priv->image_module->load_increment == NULL)) { + else if (priv->image_module->module == NULL) + gdk_pixbuf_load_module (priv->image_module); + + if ((priv->image_module->begin_load == NULL) || + (priv->image_module->stop_load == NULL) || + (priv->image_module->load_increment == NULL)) { g_warning ("module %s does not support incremental loading.\n", priv->image_module->module_name); return FALSE; } else { priv->context = (*priv->image_module->begin_load) ( gdk_pixbuf_loader_prepare, loader); - + if (priv->context == NULL) { g_warning("Failed to begin progressive load"); return FALSE; diff --git a/gtk/gdk-pixbuf-loader.c b/gtk/gdk-pixbuf-loader.c index db734ef631..ddb4ad3eec 100644 --- a/gtk/gdk-pixbuf-loader.c +++ b/gtk/gdk-pixbuf-loader.c @@ -270,16 +270,19 @@ gdk_pixbuf_loader_write (GdkPixbufLoader *loader, guchar *buf, size_t count) priv->image_module = gdk_pixbuf_get_module (priv->buf, 128); if (priv->image_module == NULL) return FALSE; - else if ((priv->image_module->begin_load == NULL) || - (priv->image_module->stop_load == NULL) || - (priv->image_module->load_increment == NULL)) { + else if (priv->image_module->module == NULL) + gdk_pixbuf_load_module (priv->image_module); + + if ((priv->image_module->begin_load == NULL) || + (priv->image_module->stop_load == NULL) || + (priv->image_module->load_increment == NULL)) { g_warning ("module %s does not support incremental loading.\n", priv->image_module->module_name); return FALSE; } else { priv->context = (*priv->image_module->begin_load) ( gdk_pixbuf_loader_prepare, loader); - + if (priv->context == NULL) { g_warning("Failed to begin progressive load"); return FALSE; -- 2.30.2